﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddDeliverTrain.aspx.cs"
    Inherits="ZX.WebApp.Crm.Deliver.AddDeliverTrain" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.calendar.js" type="text/javascript"></script>
    <link href="../../Styles/default/calendar.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
    <script src="../../Scripts/extend.validate.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <link href="../../Styles/base.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        table, td
        {
            border: 0px solid #cccccc;
            border-collapse: collapse;
        }
        .tr1
        {
            border-bottom: 1px solid #cccccc;
        }
        .style1
        {
            width: 11%;
        }
    </style>
</head>
<body class="yui-skin-sam" onkeydown="PreventBSK()">
    <form id="form1" runat="server">
    <div id="toolbar" style="margin-top: 12px; text-align: center;">
        <%if (Flag != "0" && strView == "")
          { %>
        <p id="returnBack" style="text-align: left">
            &nbsp; 退回原因：<span style="color: Red">*</span>&nbsp;
            <input type="text" id="backReason" title="不超过30个汉字" maxlength="30" style="width: 80%;" />
            <br />
        </p>
        <%} %>
        <button type="button" id="btnSave" name="btnSave">
            保存</button>
        <button type="button" id="btnQdnx" name="btnQdnx">
            保存</button>
        <button type="button" id="btnNxja" name="btnNxja">
            保存</button>
        <button type="button" id="btnMarket" name="btnMarket">
            保存</button>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" id="btnClose" name="btnClose">
            退回上一级</button>
    </div>
    <div class="fieldForm" id="fieldForm">
        <div id="content">
            <h3>
                基本信息</h3>
            <table class="table1">
                <tr>
                    <th>
                        <span>交付单号</span>
                    </th>
                    <td>
                        <asp:TextBox ID="Code" runat="server" Enabled="false" BackColor="#e7eaf4" CssClass="width60"></asp:TextBox>
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                    <th>
                        <span>申请日期</span>
                    </th>
                    <td>
                        <input type="text" id="DeliverDate" name="DeliverDate" runat="server" dtype="D" class="width60" />
                    </td>
                </tr>
                <tr>
                    <th width="10%">
                        <span style="color: Red">*</span><span>订单号</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="OrderProductID" name="OrderProductID" runat="server" />
                        <input type="text" id="txtOrderProductID" name="txtOrderProductID" runat="server"
                            disabled="disabled" class="width60" />
                        <button id="btnOrderProductID" name="3" onclick="change('1')" type="button" runat="server"
                            class="btnCheck">
                            选择</button>
                    </td>
                    <th width="10%">
                        <span>客户编码</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="CustomerCode" runat="server" disabled="disabled" class="width60" />
                    </td>
                    <th width="10%">
                        <span>客户名称</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="CustomerName" runat="server" disabled="disabled" class="width60" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>客户来源</span>
                    </th>
                    <td>
                        <input type="text" id="OrderTypeName" disabled="disabled" runat="server" class="width60" />
                    </td>
                    <th>
                        <span>主营产品</span>
                    </th>
                    <td>
                        <input type="text" id="CompanyProduct" runat="server" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>客户类型</span>
                    </th>
                    <td>
                        <input type="text" id="TypeName" runat="server" disabled="disabled" class="width60" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>信息专员</span>
                    </th>
                    <td>
                        <input type="text" id="AddUserName" runat="server" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>行销顾问</span>
                    </th>
                    <td>
                        <input type="text" id="SaleaddName" runat="server" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>一推讲师</span>
                    </th>
                    <td>
                        <input type="hidden" id="NegotiateTeach" />
                        <input type="text" id="LectorName" runat="server" disabled="disabled" class="width60" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>客户经理</span>
                    </th>
                    <td>
                        <input type="hidden" id="CustomerMgr" name="CustomerMgr" runat="server" />
                        <input type="text" runat="server" id="txtCustomerMgr" name="txtCustomerMgr"
                            disabled="disabled" class="width60" />
                        <button id="btnCustomerMgr" name="Z" type="button" runat="server" class="btnCheck" style="height: 25px;">
                            选择</button>
                    </td>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtXm" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span style="color: Red">*</span> <span>负责交付人</span>
                    </th>
                    <td>
                        <input type="hidden" id="ClassFrontServer" />
                        <input type="text" id="txtClassFrontServer" runat="server" disabled="disabled" class="width60" />
                        <button id="btnClassFrontServer" runat="server" name="Z" type="button" onclick="change('0')"
                            class="btnCheck">
                            选择</button>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>客户总监</span>
                    </th>
                    <td>
                        <input type="hidden" id="CustomerDirector" runat="server" />
                        <input type="text" runat="server" id="txtCustomerDirector" disabled="disabled" class="width60" />
                        <button id="btnCustomerDirector" name="Z" type="button" runat="server" class="btnCheck" style="height: 25px;">
                            选择</button>
                    </td>
                    <th>
                        <span>分总</span>
                    </th>
                    <td>
                        <input type="hidden" id="CustomerManager" runat="server" />
                        <input type="text" runat="server" id="txtCustomerManager" disabled="disabled" class="width60" />
                        <button id="btnCustomerManager" name="Z" type="button" runat="server" class="btnCheck" style="height: 25px;">
                            选择</button>
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr style="display: none;">
                    <td id="tdState1" style="display: none;">
                        <span>状态</span>
                    </td>
                    <td id="tdState2" style="display: none;">
                        <asp:DropDownList ID="DliverState" runat="server" CssClass="width65">
                        </asp:DropDownList>
                    </td>
                    <td colspan="4">
                        &nbsp;
                    </td>
                </tr>
            </table>
        </div>
        <div class="extendDiv">
            <div id="con_two_1">
                <div id="con_1">
                </div>
            </div>
        </div>
        <div class="contentTable">
            <table id="pm" class="table1">
                <tr>
                    <th width="10%">
                        <span style="color: Red">*</span><span>内训讲师</span>
                    </th>
                    <td width="21%">
                        <input type="hidden" id="Memember" runat="server" />
                        <input type="text" id="txtMemember" runat="server" dtype="Z" disabled="disabled"
                            class="width60" />
                        <button id="btnMemember" name="R" type="button" runat="server" class="btnCheck">
                            选择</button>
                    </td>
                    <th width="10%">
                        <span style="color: Red">*</span><span>启动日期</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="txtStartDate" runat="server" class="width60" />
                    </td>
                    <th width="10%">
                        <span>备注</span>
                    </th>
                    <td width="21%">
                        <input type="text" id="txtPmExplain" maxlength="30" title="不超过30个汉字" runat="server"
                            class="width60" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="AddUser" runat="server" />
                        <input type="text" runat="server" id="txtAddUser" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtAddTime" disabled="disabled" class="width60" />
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>实施天数</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtDay" onkeyup="this.value=this.value.replace(/[^\d\.]/g,'')"
                            onafterpaste="this.value=this.value.replace(/[^\d\.]/g,'')" class="width60" />
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>结案日期</span>
                    </th>
                    <td>
                        <input type="text" id="txtEndTime" runat="server" class="width60" />
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        <div id="con_5">
                        </div>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="hdnEnd" runat="server" />
                        <input type="text" runat="server" id="txtEndUser" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtEndWriteTime" disabled="disabled" class="width60" />
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>外部客户评分</span>
                    </th>
                    <td>
                        <input type="text" id="txtSatisfy" maxlength="3" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" class="width60" />分(0-100)
                    </td>
                    <th>
                        <span style="color: Red">*</span><span>内部客户评分</span>
                    </th>
                    <td>
                        <input type="text" id="txtInnerGrade" maxlength="3" runat="server" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')" class="width60" />分(0-100)
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>外部客户评价</span>
                    </th>
                    <td colspan="5">
                        <textarea id="txtOut" runat="server" onkeydown="showSetNum('txtOut','spTcont',500)"
                            onkeyup="showSetNum('txtOut','spTcont',500)" title="不超过500个汉字" rows="3" style="width: 60%;"></textarea>
                        <span id="spTcont" class="span_font"></span>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span style="color: Red">*</span><span>内部客户评价</span>
                    </th>
                    <td colspan="5">
                        <textarea id="txtInner" runat="server" onkeydown="showSetNum('txtInner','spInner',500)"
                            onkeyup="showSetNum('txtInner','spInner',500)" title="不超过500个汉字" rows="3" style="width: 60%;">    </textarea><span
                                id="spInner" class="span_font"></span>
                    </td>
                </tr>
                <tr>
                    <th>
                        <span>填写人</span>
                    </th>
                    <td>
                        <input type="hidden" id="hdnMyd" runat="server" />
                        <input type="text" runat="server" id="txtMydUser" disabled="disabled" class="width60" />
                    </td>
                    <th>
                        <span>填写时间</span>
                    </th>
                    <td>
                        <input type="text" runat="server" id="txtMydTime" disabled="disabled" class="width60" />
                    </td>
                    <td colspan="2">
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr>
            </table>
        </div>
        <div>
            <table id="tbReturn" class="tableContent" style="width: 100%" border="1">
                <tr>
                    <td style="height: 16px; text-align: center" colspan="3">
                        <asp:GridView ID="gvworkflowMessage" CssClass="GridViewStyle" runat="server" AutoGenerateColumns="False"
                            Width="100%">
                            <Columns>
                                <asp:BoundField DataField="WorkFlowNo" HeaderText="流程编号">
                                    <ItemStyle Width="8%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="TaskInstanceCaption" HeaderText="任务名称">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="FlowCaption" HeaderText="流程名称">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="OperatedDes" HeaderText="处理者">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" HtmlEncode="False" DataField="taskEndTime"
                                    HeaderText="任务结束时间">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="Message" HeaderText="审批意见">
                                    <ItemStyle Width="15%" />
                                </asp:BoundField>
                                <asp:BoundField DataField="SuccessMsg" HeaderText="状态">
                                    <ItemStyle Width="10%" />
                                </asp:BoundField>
                            </Columns>
                            <FooterStyle CssClass="FooterStyle" />
                            <RowStyle CssClass="RowStyle" />
                            <EmptyDataRowStyle CssClass="EmptyRowStyle" />
                            <PagerStyle CssClass="PagerStyle" />
                            <SelectedRowStyle CssClass="SelectedRowStyle" />
                            <HeaderStyle CssClass="HeaderStyle" />
                            <EditRowStyle CssClass="EditRowStyle" />
                            <AlternatingRowStyle CssClass="AltRowStyle" />
                        </asp:GridView>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            信息选择</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <input type="hidden" id="ID" runat="server" />
    <input type="hidden" id="WorkFlowInsId" runat="server" />
    <input type="hidden" id="WorkTaskInsId" runat="server" />
    </form>
    <form id="form2" style="display: none" action="">
    <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    </form>
</body>
<script type="text/javascript">
var entity = "<% =EntityName %>",addUser="<%=addUser %>",
    action = "<% =DataAction %>",
    flag = "<%=Flag %>", strView="<%=strView %>",
    WorkFlowId="<%=strWorkFlowId %>",WorkTaskId="<%=strWorkTaskId %>",strOperStatus="<%=strOperStatus %>", strDescript="<%=strDescript %>",
    OperatorInstanceId="<%=strOperatorInstanceId %>",WorkflowInsId="<%=strWorkflowInsId %>",  WorkTaskInsId=$("#WorkTaskInsId").val(),
    ListRecord=[<%=ListRecord %>],vTeacher=[<%=Teacher %>]; ;
var CrmProduct = [<%=ListRecord %>];   
var  DeliverMajorInfo = [<%=StrDeliverTrainInfo %>];
var myDataSource1, mDataTable1;
var getTsid=$("#WorkTaskInsId").val();
var vid = $("#ID").val();
var btnSave = "",btnQdnx="",btnNxja="",btnMarket="", btnClose = "", condition = "";
<asp:Literal ID="EditTemplate" runat="server"></asp:Literal>
(function () { 

    if (strView!="check") {

    var trs = $("#pm tr");  
    if(strDescript=="qdnx"){
        
        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=2){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }else if(strDescript=="nxja"){

        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=6){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }else if(strDescript=="market"){

        for (var i = 0; i < trs.length; i++) {
            if(i>=0&&i<=10){
                trs[i].style.display = "block";
            }else{
                trs[i].style.display = "none"; 
            }
        }
    }
    else{    
        for (var i = 0; i < trs.length; i++) {
            trs[i].style.display = "none"; 
        }
            
    }      
}
    var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
    Event.onDOMReady(function () {
        var layout = new YAHOO.widget.Layout({
            units: [
            { position: 'bottom', height: 90, body: 'toolbar', gutter: '1 1 1 1', scroll: null, zIndex: 2 },
            { position: 'center', body: 'fieldForm', gutter: '0 1 1 1', scroll: true }
            ]
        });
        layout.render();
    });
})();
//退回上一节点
var Close = function () {
    if($("#backReason").val()==""){
        alert("请填写退回原因");
        $("#backReason").focus();
        return;
    }
    var vMessage = $("#backReason").val();
    if (confirm("您确定退回?")) {
    setTimeout(function () {
        var btn = document.getElementById("btnClose");
        btn.disabled = true;
        var SaveUrl = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=check&entity=CrmDeliverTrainUnAgree&msg=" + encodeURI(vMessage) + "" +
            "&OperatorInstanceId=" + OperatorInstanceId + "&WorkflowId=" + WorkFlowId + "&WorktaskId=" + WorkTaskId + "&WorkflowInsId=" + WorkflowInsId + "&WorktaskInsId=" + WorkTaskInsId + "";
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        window.location.href = "../../Crm/BasePages/tooltip.aspx?worktaskInstanceId=" + getTsid;
                    } else {
                        alert("数据保存失败!");
                        return;
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
            setTimeout(function () { btn.disabled = false }, 10000);
        }, 10);         
    }
    //window.parent.$("#tabs").tabs('close', '<%=PageTitle %>');
}
var csNum;
var change=function(obj){
    csNum=obj
}

YAHOO.example.init = function () {
    function onButtonClick(p_oEvent) {
        switch (this.get("id")) {
            case "btnSave":      
                Save(0);
                break;
            case "btnClose":
                Close();
                break;
            case "btnQdnx":
                SaveQdnx();
                break;
                case "btnNxja":
                SaveNxja();
                break;
                case "btnMarket":
                SaveMarket();
                break;
            default:
                break;
        }
    }
    YAHOO.util.Event.onContentReady("toolbar", function () {
        btnSave = new YAHOO.widget.Button("btnSave");
        btnSave.on("click", onButtonClick);
        btnQdnx = new YAHOO.widget.Button("btnQdnx");
        btnQdnx.on("click", onButtonClick);
        btnNxja = new YAHOO.widget.Button("btnNxja");
        btnNxja.on("click", onButtonClick);
        btnMarket = new YAHOO.widget.Button("btnMarket");
        btnMarket.on("click", onButtonClick);
        btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", onButtonClick); 
        if(strView=="check"){
            btnQdnx._button.style.display = "none";
            $("#btnQdnx").attr('disabled', "true");
            btnNxja._button.style.display = "none";
            $("#btnNxja").attr('disabled', "true");
            btnMarket._button.style.display = "none";
            $("#btnMarket").attr('disabled', "true");
            btnClose._button.style.display = "none";
            $("#btnClose").attr('disabled', "true"); 
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
        } else{
        if(strDescript=="qdnx"){    
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            btnNxja._button.style.display = "none";
            $("#btnNxja").attr('disabled', "true");
            btnMarket._button.style.display = "none";
            $("#btnMarket").attr('disabled', "true");
        }
        else if(strDescript=="nxja"){
            btnQdnx._button.style.display = "none";
            $("#btnQdnx").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
            btnMarket._button.style.display = "none";
            $("#btnMarket").attr('disabled', "true");
        }
        else if(strDescript=="market"){
            btnQdnx._button.style.display = "none";
            $("#btnQdnx").attr('disabled', "true");
            btnNxja._button.style.display = "none";
            $("#btnNxja").attr('disabled', "true");
            btnSave._button.style.display = "none";
            $("#btnSave").attr('disabled', "true");
        }
        else{ //新增时设置按钮隐藏
            btnQdnx._button.style.display = "none";
            $("#btnQdnx").attr('disabled', "true");
            btnNxja._button.style.display = "none";
            $("#btnNxja").attr('disabled', "true");
            btnMarket._button.style.display = "none";
            $("#btnMarket").attr('disabled', "true");
            btnClose._button.style.display = "none";
            $("#btnClose").attr('disabled', "true");
        }    }
    });
      
} ();
//选择对应的方法和ID
var _fn, _id;
function ShowDialog(fn, id,src) {
    _fn = fn;
    _id = id;
    document.getElementById("EditUIWindow1").src = src;
    YAHOO.example.container.dialog1.show();
}
/* 对应的方法和ID*/
var _fn, _id;
function ShowDialog1(fn, id,src) {
    _fn = fn;
    _id = id;
    document.getElementById("EditUIWindow1").src = src;
    YAHOO.example.container.dialog1.show();
}
YAHOO.namespace("example.container");
YAHOO.util.Event.onDOMReady(function () {
    var handleSubmit = function () {
        var editwindow = document.getElementById("EditUIWindow1");
        if (editwindow) {
            editwindow.contentWindow.ChooseInfo();    
            if(csNum=="1"){ LoadOrderProductInfo();}
        }
        YAHOO.example.container.dialog1.hide();
    };
    var handleCancel = function () {
        this.cancel();
    };
    var handleSuccess = function (o) {
        var response = o.responseText;
        response = response.split("<!")[0];
        document.getElementById("resp").innerHTML = response;
    };
    var handleFailure = function (o) {
        alert("Submission failed: " + o.status);
    };
    YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					        { width: "580px",
					            height: "450px",
					            fixedcenter: true,
					            visible: false,
					            draggable: true,
					            close: true,
					            autofillheight: "body",
					            constraintoviewport: true,
					            buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								        { text: "取消", handler: handleCancel}]
					        });
    YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
    YAHOO.example.container.dialog1.render();
    });
    //根据订单产品ID获取订单信息
    var LoadOrderProductInfo = function () {           
    var vCId = "OrderCode='" + $("#txtOrderProductID").val() + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_DeliverOrderProduct&customCondition=" + vCId + "", //条件 
        {success: function (res) {
            try {
                var str = res.responseText; 
                var arr = []; var entity = {};
                var obj = eval(str); 
                $('#CustomerCode').val(obj[0].CustomerCode);
                $('#CustomerName').val(obj[0].CustomerName);
                $('#OrderTypeName').val(obj[0].CustomerOrigin);
                $('#CompanyProduct').val(obj[0].CompanyProduct);
                $('#TypeName').val(obj[0].CustomerType);
                $('#AddUserName').val(obj[0].CInfoer);
                $('#SaleaddName').val(obj[0].CSaler);
                $('#CustomerMgr').val(obj[0].CustomeerMgr);
                $('#txtCustomerMgr').val(obj[0].CManager);
                $('#LectorName').val(obj[0].CTeacher);

                LoadCustomerDirector(obj[0].OrderID);
                LoadData1();
            }
            catch (e) {
            }
            finally {
            }
        }, failure: function () { }
    });
}
//加载显示客户总监和分总
var LoadCustomerDirector = function (OrderId) {
    var vCId = "OrderId='" + OrderId + "'";
    YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_CrmOrderPerson&customCondition=" + vCId + "",
    { success: function (res) {
        try {
            var str = res.responseText;
            var arr = [];
            var obj = eval(str);
            for (var i = 0; i < obj.length; i++) {
                if (obj[i].ClassValue == "CustomerZJ") {
                    $("#CustomerDirector").val(obj[i].UserId);
                    $("#txtCustomerDirector").val(obj[i].UserName);
                }
                if (obj[i].ClassValue == "CustomerFZ") {
                    $("#CustomerManager").val(obj[i].UserId);
                    $("#txtCustomerManager").val(obj[i].UserName);
                }
            }
        }
        catch (e) {
        }
        finally {
        }
    }, failure: function () { }
    });
}
//加载数据
var LoadData1 = function () {        
    var vCId = "OrderCode='" + $("#txtOrderProductID").val() + "' and  PhraseID='CED37B58-A821-40F6-A6D6-2DA9035DDDF5'";
        YAHOO.util.Connect.asyncRequest('GET', "../../Extend/AjaxData/JSONList.aspx?r=" + Math.random() + "&type=1&entity=V_DeliverOrderProduct&customCondition=" + vCId + "", //条件 
            {success: function (res) {
                try {         
                    var str = res.responseText;
                    var arr = [];          
                    var obj = eval(str);
                    if(obj.length==0){
                        alert("请选择有内训产品的订单");   
                        return;
                    }        
                    for (var i = 0; i < obj.length; i++) {
                        var entity = {};
                        entity.ProductName = obj[i].ProductName;
                        entity.ID = obj[i].ProductId;
                        entity.AccountReceivable = obj[i].AccountReceivable;
                        if(obj[i].ResignMoney==""){
                            entity.ResignMoney="0";   
                        }else{
                            entity.ResignMoney = obj[i].ResignMoney;
                        }
                        entity.ID=obj[i].ID;
                        entity.Amount=obj[i].Amount;
                        entity.UnitName=obj[i].UnitName;
                        entity.TypeName=obj[i].TypeName;
                        entity.ProductCode = obj[i].ProductCode;
                        arr.push(entity);
                    }
                    ListRecord = arr;
                    hideCol();
                } catch (e) {
                    ListRecord = "";
                    hideCol();
                    alert("请选择有内训产品的订单");  
                    return;
                }
                finally {
                }
        }, failure: function () { }
    });
}
var format1 = function (elCell, oRecord, oColumn, sData) {                                           
    var str1 = [];
    var id = "id" + Math.random();
    str1.push("<option value='00'> </option>");
    if(strView=="unDone"||strDescript!="") {
    str1.push("<select id='" + id + "' onchange='ChangeEvent2(this);' disabled='disabled' name='ProductName' style='width:95%'>");
    }else{
        str1.push("<select id='" + id + "' onchange='ChangeEvent2(this);' name='ProductName' style='width:95%'>");
    } str1.push("<option value='00'> </option>"); 
    for (var i = 0; i < ListRecord.length; i++) {  
        if (sData==null||sData==""|| ListRecord[i].ID==sData) {    
            str1.push("<option value='" + ListRecord[i].ID + "'>" + ListRecord[i].ProductName + "</option>");
        }else{
            if (ListRecord[i].ProductName == sData) {
                str1.push("<option value='" + ListRecord[i].ID + "' selected>" + ListRecord[i].ProductName + "</option>");
            } 
        }
    }
    str1.push("</select>");
    elCell.innerHTML = str1.join("");
}
var format2 = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData=="") {
        elCell.innerHTML = "<input type=\"text\" value=\"\" disabled='disabled' name='ProductCode' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" disabled='disabled' onchange='ChangeEvent1(this);' name='ProductCode' style='width:95%; background: #e7eaf4;'>";
    }            
}
var format3 = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData=="") {
        elCell.innerHTML = "<input type=\"text\" value=\"\" disabled='disabled' name='TypeName' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" disabled='disabled' onchange='ChangeEvent1(this);' name='TypeName' style='width:95%; background: #e7eaf4;'>";
    }
}                                       
var format4 = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData=="") {
        elCell.innerHTML = "<input type=\"text\" value=\"\" disabled='disabled' name='Amount' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" disabled='disabled' name='Amount' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }
}
var format5 = function (elCell, oRecord, oColumn, sData) { 
    if (sData==null||sData=="") { 
        elCell.innerHTML = "<input type=\"text\" value=\"\" disabled='disabled' name='UnitName' style='width:95%; background: #e7eaf4;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" disabled='disabled' name='UnitName' style='width:95%; background: #e7eaf4;'>";
    }
}
var format6 = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData=="") { 
        elCell.innerHTML = "<input type=\"text\" value=\"\" disabled='disabled' name='AccountReceivable' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" disabled='disabled' name='AccountReceivable' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }
}
var format7 = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData=="") {
        elCell.innerHTML = "<input type=\"text\" value=\"0\" disabled='disabled' name='ResignMoney' onchange='ChangeEvent1(this);' style='width:95%; background: #e7eaf4;'>";
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\" disabled='disabled' onchange='ChangeEvent1(this);' name='ResignMoney' style='width:95%; background: #e7eaf4;'>";
    }
}
var format8 = function (elCell, oRecord, oColumn, sData) {    
    var str1 = [];
    var id = "id" + Math.random();
    //str1.push("<option value='00'> </option>");
    // str1.push("<select id='" + id + "' onchange='ChangeEvent1(this);' name='IsDecision' style='width:70px;'>");
        if(strDescript!="") {
    str1.push("<select id='" + id + "'  name='IsSingleTrain'  onchange='ChangeEvent1(this);' disabled='disabled' style='width:70px;'>");
    }else{
        str1.push("<select id='" + id + "'  name='IsSingleTrain' onchange='ChangeEvent1(this);' style='width:70px;'>");
    }if (sData==null||sData=="") {
        str1.push("<option value='0' selected>否</option>"); 
        str1.push("<option value='1'>是</option>");
    }else{
    if (sData=="1") {
        str1.push("<option value='1' selected>是</option>"); 
        str1.push("<option value='0'>否</option>");
    }else{
        str1.push("<option value='0' selected>否</option>"); 
        str1.push("<option value='1'>是</option>");
        }
    }      
    str1.push("</select>");
    elCell.innerHTML = str1.join("");
}
var format9 = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData==""||sData=="null") {
        if(strDescript!=""){
            elCell.innerHTML = "<input type=\"text\" value=\"\"  name='TrainSum' disabled='disabled' onchange='ChangeEvent1(this);' style='width:95%;'>";
        }else{
        elCell.innerHTML = "<input type=\"text\" value=\"\"  name='TrainSum' onchange='ChangeEvent1(this);' style='width:95%;'>";
    } }else{
            if(strDescript!=""){
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\"  onchange='ChangeEvent1(this);' disabled='disabled' name='TrainSum' style='width:95%;'>";
        }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\"  onchange='ChangeEvent1(this);' name='TrainSum' style='width:95%;'>";
        }} 
}
var formatDays = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData==""||sData=="null") {
        elCell.innerHTML = "<input type=\"text\" value=\"\"  onchange='ChangeEvent3(this);' name='ImplenmentFate' style='width:95%;'>"; 
    }else{
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\"  onchange='ChangeEvent3(this);' name='ImplenmentFate' style='width:95%;'>"; 
    }
}
var formatExplain = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData==""||sData=="null") {
        elCell.innerHTML = "<input type=\"text\" value=\"\"  onchange='ChangeEvent3(this);' name='Explain' style='width:95%;'>"; 
    }else{  
        elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\"  onchange='ChangeEvent3(this);' name='Explain' style='width:95%;'>"; 
    }
}
var formatTeacher = function (elCell, oRecord, oColumn, sData) {
    if (sData==null||sData==""||sData=="null") {
        elCell.innerHTML = "<input type=\"text\" value=\"\"  onchange='ChangeEvent3(this);' disabled='disabled' name='Exp2' style='width:95%;background: #e7eaf4;'>"; 
    }else{  
        if(strDescript=="nxja"){
            elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\"  disabled='disabled' onchange='ChangeEvent3(this);' name='Exp2' style='width:95%;background: #e7eaf4;'>"; 
        }else{
            elCell.innerHTML = "<input type=\"text\" value=\"" + sData + "\"  disabled='disabled' onchange='ChangeEvent3(this);' name='UName' style='width:95%;background: #e7eaf4;'>"; 
        }
    }
}
YAHOO.util.Event.addListener(window, "load", function () {
    BindData();   
    BindDataTeacher();
    hideCol(); 
    hideTeacherCol();
    if (flag=="1") {
        LoadData1();
    }
});
var BindDataTeacher = function () {
    YAHOO.example.RowDataMod = function () {  
    if(strDescript=="nxja"){
        var myColumnDefs5 = [
        { key: "Exp1", label: "ID", resizeable: true },
        { key: "Exp2", label: "讲师名称", resizeable: true, formatter: formatTeacher },
        { key: "ImplenmentFate", label: "实施天数", resizeable: true, formatter: formatDays },
        { key: "Explain", label: "备注", resizeable: true, formatter: formatExplain }
        ];
        myDataSource5 = new YAHOO.util.DataSource([{ Exp1: "",
            Exp2: "", ImplenmentFate: "", Explain: ""
        }]);
        myDataSource5.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        myDataSource5.responseSchema = {
            fields: ["Exp1",
            "Exp2", "ImplenmentFate", "Explain"]
        };
        var myDataTable5 = new YAHOO.widget.DataTable("con_5",
        myColumnDefs5, myDataSource5, { selectionMode: "single" });
        mDataTable5 = myDataTable5; }else{
            var myColumnDefs5 = [
        { key: "Exp1", label: "ID", resizeable: true },
        { key: "UName", label: "讲师名称", resizeable: true, formatter: formatTeacher },
        { key: "ImplenmentFate", label: "实施天数", resizeable: true, formatter: formatDays },
        { key: "Explain", label: "备注", resizeable: true, formatter: formatExplain }
        ];
        myDataSource5 = new YAHOO.util.DataSource([{ Exp1: "",
            UName: "", ImplenmentFate: "", Explain: ""
        }]);
        myDataSource5.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        myDataSource5.responseSchema = {
            fields: ["Exp1",
            "UName", "ImplenmentFate", "Explain"]
        };
        var myDataTable5 = new YAHOO.widget.DataTable("con_5",
        myColumnDefs5, myDataSource5, { selectionMode: "single" });
        mDataTable5 = myDataTable5;
        }
        var i5 = 1,
        bReverseSorted5 = false;
        var trackReverseSorts5 = function (oArg) {
            bReverseSorted5 = (oArg.dir === YAHOO.widget.DataTable.CLASS_DESC);
        };
        myDataTable5.subscribe("rowMouseoverEvent", myDataTable5.onEventHighlightRow);
        myDataTable5.subscribe("rowMouseoutEvent", myDataTable5.onEventUnhighlightRow);
        myDataTable5.subscribe("rowClickEvent", myDataTable5.onEventSelectRow);
        myDataTable5.subscribe("checkboxClickEvent", function (oArgs) {
            var elCheckbox = oArgs.target;
            var oRecord = this.getRecord(elCheckbox);
            oRecord.setData("iSun_Selected", elCheckbox.checked);
        });
        GetFormValue5();
        return {
            ds: myDataSource5,
            dt: myDataTable5
        };
    } ();
}
var GetFormValue5 = function () {
    for (var i = 0; i < vTeacher.length; i++) {
        SetFormValue5(vTeacher);
    }
}
var SetFormValue5 = function (obj) {
    var arr = eval(obj);
    myDataSource5.liveData = arr;
    mDataTable5.getDataSource().sendRequest(null, { success: mDataTable5.onDataReturnInitializeTable }, mDataTable5);
}
var BindData = function () {
    YAHOO.example.RowDataMod = function () {
        var myColumnDefs1 = [
        { key: "ID", label: "ID", resizeable: true },
        { key: "ProductName", label: "产品名称", resizeable: true, formatter: format1,width:200 },
        { key: "ProductCode", label: "产品编码", resizeable: true, formatter: format2 },
        { key: "TypeName", label: "产品类型", resizeable: true, formatter: format3 },
        { key: "Amount", label: "数量", resizeable: true, formatter: format4,width:60 },
        { key: "UnitName", label: "计量单位", resizeable: true, formatter: format5,width:60 },
        { key: "AccountReceivable", label: "应收金额", resizeable: true, formatter: format6 },
        { key: "ResignMoney", label: "已收金额", resizeable: true, formatter: format7 },
        { key: "IsSingleTrain", label: "独立内训", resizeable: true, formatter: format8 },
        { key: "TrainSum", label: "内训天数", resizeable: true, formatter: format9 }
        ];
        myDataSource1 = new YAHOO.util.DataSource([{ ID: "",ProductName: "", ProductCode: "", TypeName:"",
            Amount: "", UnitName: "", AccountReceivable: "", ResignMoney: "", IsSingleTrain: "", TrainSum: ""
        }]);
        myDataSource1.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        myDataSource1.responseSchema = {
            fields: ["ID", "ProductName", "ProductCode", "TypeName", "Amount",  "UnitName", "AccountReceivable", "ResignMoney", "IsSingleTrain", "TrainSum"]
        };
        var myDataTable1 = new YAHOO.widget.DataTable("con_1",
        myColumnDefs1, myDataSource1, { selectionMode: "single" });
        mDataTable1 = myDataTable1;
        var i1 = 1,
        bReverseSorted1 = false;
        var trackReverseSorts1 = function (oArg) {
            bReverseSorted1 = (oArg.dir === YAHOO.widget.DataTable.CLASS_DESC);
        };
        myDataTable1.subscribe("rowMouseoverEvent", myDataTable1.onEventHighlightRow);
        myDataTable1.subscribe("rowMouseoutEvent", myDataTable1.onEventUnhighlightRow);
        myDataTable1.subscribe("rowClickEvent", myDataTable1.onEventSelectRow);
        myDataTable1.subscribe("checkboxClickEvent", function (oArgs) {
            var elCheckbox = oArgs.target;
            var oRecord = this.getRecord(elCheckbox);
            oRecord.setData("iSun_Selected", elCheckbox.checked);
        });
        GetFormValue1();         
        return {
            ds: myDataSource1,
            dt: myDataTable1
        };
    } ();
}
function hideCol() {
    mDataTable1.hideColumn(parseInt(0)); mDataTable1.refreshView();
}
function hideTeacherCol(){
    mDataTable5.hideColumn(parseInt(0)); mDataTable5.refreshView();
}
var GetFormValue1 = function () {      
    for (var i = 0; i < DeliverMajorInfo.length; i++) {
        SetFormValue1(DeliverMajorInfo);
    }
}
var SetFormValue1 = function (obj) {
    var arr = eval(obj);   
    myDataSource1.liveData = arr;
    mDataTable1.getDataSource().sendRequest(null, { success: mDataTable1.onDataReturnInitializeTable }, mDataTable1);
}

//值改变事件
var ChangeEvent1 = function (oArgs) {
    var f = oArgs.name;
    var v = oArgs.value;
    setValue1(f, v);
}
var ChangeEvent2 = function (oArgs) {
    var f = oArgs.name;
    var v = oArgs.value;
    var num=oArgs.selectedIndex;
    setValue2(f, v,num);
}
var ChangeEvent3 = function (oArgs) {
    var f = oArgs.name;
    var v = oArgs.value;
    setValue3(f, v);
}
//f=字段名 v=值
var setValue3 = function (f, v) {
    var recordID = mDataTable5.getSelectedRows()[0];
    var record = mDataTable5.getRecord(recordID);
    record._oData[f] = v;
    if (f == "ImplenmentFate") {
        if (isNaN(v)) {
            alert("实施天数必须输入数字!");
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ImplenmentFate]")[0]).val("");
            record._oData["ImplenmentFate"] = "";
        }
    }
}
var setValue2 = function (f, v, num) {    
    var recordID = mDataTable1.getSelectedRows()[0];
    var record = mDataTable1.getRecord(recordID);
    record._oData[f] = v; 
    if(num==0){
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=TypeName]")[0]).val("");
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ProductCode]")[0]).val("");
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=Amount]")[0]).val("");$($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ResignMoney]")[0]).val("");
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=UnitName]")[0]).val("");
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=AccountReceivable]")[0]).val("");
    }      
    for (var i = 0; i < ListRecord.length; i++) {
        if (ListRecord[i].ID == v&&num==i+1) {
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=TypeName]")[0]).val(ListRecord[i].TypeName);
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ProductCode]")[0]).val(ListRecord[i].ProductCode);
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=Amount]")[0]).val(ListRecord[i].Amount);
        if(ListRecord[i].ResignMoney==""){
                ListRecord[i].ResignMoney  ="0";
        }
        if(ListRecord[i].ResignMoney=="0"){
            alert("已收金额必须大于0，您需先填写缴款单");
            var btn = document.getElementById("btnSave");
                this.window.location=window.location;
        }else{
                var btn = document.getElementById("btnSave");
                btn.disabled = false;
        }
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=ResignMoney]")[0]).val(ListRecord[i].ResignMoney);
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=UnitName]")[0]).val(ListRecord[i].UnitName);
        $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=AccountReceivable]")[0]).val(ListRecord[i].AccountReceivable);
        }
    }
}
//f=字段名 v=值
var setValue1 = function (f, v) {
    var recordID = mDataTable1.getSelectedRows()[0];
    var record = mDataTable1.getRecord(recordID);
    record._oData[f] = v;
    if (f == "TrainSum") {
        if (isNaN(v)) {
            alert("内训天数必须输入数字!");
            $($(event.srcElement.parentNode.parentNode.parentNode).find("input[name=TrainSum]")[0]).val("");
            record._oData["TrainSum"] = "";
        }
    }
}
//刷新父窗体数据
function RefreshDataParent() {
    if (parent.NeedRefreshPage != null) {
        if (typeof (parent.NeedRefreshPage.LoadData) == "function") {
            parent.NeedRefreshPage.RefreshData();
        }
    }
}

//保存
var Save = function (obj) {  
    $("#DliverState").get(0).selectedIndex =2;     
    setValue();           
                
    if(instance[0].ClassFrontServer == null || instance[0].ClassFrontServer ==  ""){
        if(strView=="unDone"){
            instance[0].ClassFrontServer="00000000-0000-0000-0000-000000000000"; 
        } else{ 
            alert("负责交付人不能为空!");
            return;
        }
    } 
    var list = mDataTable1.getRecordSet()._records;
    if (list[0]._oData.ProductName ==null || list[0]._oData.ProductName ==  "") {
        alert("产品名称不能为空!");
        return;
    }
         
    if(strView!="unDone"){
        //alert(list[0]._oData.ProductName);
        instance[0].exp1= list[0]._oData.ProductName;     
    }
    if (list[0]._oData.IsSingleTrain ==null){ 
        instance[0].IsSingleTrain="0";
    }else{
        instance[0].IsSingleTrain= list[0]._oData.IsSingleTrain;
    }
    if (list[0]._oData.TrainSum ==null){ 
        instance[0].TrainSum= 0;
    }else{
        instance[0].TrainSum= list[0]._oData.TrainSum;
    }
    var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
    $("#jsonDataContent").val(json);
    setTimeout(function () {
        var btn = document.getElementById("btnSave");
        btn.disabled = true;
            trySave();
        setTimeout(function () { btn.disabled = false }, 10000);
    }, 10);
}
//保存内训人员
var SaveQdnx=function(){ 
    $("#DliverState").get(0).selectedIndex =1; 
    setQdnxValue();
        var orderid="<%=strOrderId %>",productid="<%=strProductId %>";
    if(strOperStatus!="1"){
    if(instance[0].PMemember==null||instance[0].PMemember=="") {
        alert("内训讲师不能为空!");
        return;
    }
    if(instance[0].BeginDate==null||instance[0].BeginDate=="") {
        alert("启动日期不能为空!");
        return;
    }}else{  
        /*var tempBd="<%=strStartDate %>",tempPmb="<%=strMemember %>",tempEpx="<%=strExplain %>" ;              
        instance[0].BeginDate=tempBd; 
        instance[0].PMemember=tempPmb; 
        instance[0].PExplain=tempEpx;*/ 
    }                           
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&stateId="+$("#DliverState").val()+"&orderid="+orderid+"&productid="+productid+"&view="+strOperStatus+"&BeginDate="+instance[0].BeginDate+"&PMemember="+instance[0].PMemember+"&PExplain="+encodeURI(instance[0].PExplain)+"&ProjectUser="+instance[0].ProjectUser+"&ProjectDate="+instance[0].ProjectDate+"&flag=1&entity="+entity+"&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
        
    setTimeout(function () {
                var btn = document.getElementById("btnQdnx");
                btn.disabled = true;
                var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
                setTimeout(function () { btn.disabled = false }, 10000);
            }, 10);
}
//实施资料
var SaveNxja=function(){  
    $("#DliverState").get(0).selectedIndex = 4;   
    setNxjaValue();
    if(instance[0].DateSum==null||instance[0].DateSum=="") {
        alert("实施天数不能为空!");
        return;
    }
    if(instance[0].EndDate==null||instance[0].EndDate=="") {
        alert("结案日期不能为空!");
        return;
    }
    var endDate = "<%=strEndDate %>";
    if (instance[0].EndDate > endDate) {
        alert("结案日期不能大于当前日期!");
        $('#txtEndTime').focus();
        return ;
    }
    if (instance[0].EndDate < $("#txtStartDate").val()) {
        alert("结案日期不能早于启动日期!");
        $('#txtEndTime').focus();
        return ;
    } 
    var list = mDataTable5.getRecordSet()._records;
    var elist = [];
    for (var i = 0; i < list.length; i++) {
        if (list[i]._oData.ImplenmentFate == null || list[i]._oData.ImplenmentFate == "" ) {
            alert("第" + (i + 1) + "行 讲师天数不能为空!");
            return;
        }
        elist.push(list[i]._oData);
    }
    var ProduectList="";
    for (var j = 0; j < elist.length; j++) {
        ProduectList += "@" + $("#ID").val()+ "︾" + elist[j].Exp1 + "︾" +elist[j].ImplenmentFate + "︾" + elist[j].Explain + "︾";
    }        
    var strOrderProduct="<%=strOrderProduct %>"; 
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&DliverState="+$("#DliverState").val()+"&strOrderProduct="+strOrderProduct+"&DateSum="+instance[0].DateSum+"&ProduectList="+encodeURI(ProduectList)+"&EndDate="+instance[0].EndDate+"&SsUser="+instance[0].SsUser+"&SsDate="+instance[0].SsDate+"&flag=1&entity=CrmDeliverTrainSsr&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    setTimeout(function () {
        var btn = document.getElementById("btnNxja");
        btn.disabled = true;
        var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
        setTimeout(function () { btn.disabled = false }, 10000);
    }, 10);
}
var setNxjaValue=function(){
    instance[0].DateSum=$("#txtDay").val();
    instance[0].EndDate=$("#txtEndTime").val();
    instance[0].SsUser=$("#hdnEnd").val();
    instance[0].SsDate=$("#txtEndWriteTime").val(); 
}
//市场部
var SaveMarket=function(){  
    setMarketValue();
    if(instance[0].WellDegree==null||instance[0].WellDegree=="") {
        alert("外部客户评分不能为空!");
        $("#txtSatisfy").focus();
        return;
    }
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action=update&exp="+instance[0].exp3+"&InnerValue="+encodeURI(instance[0].InnerValue)+"&OutValue="+encodeURI(instance[0].OutValue)+"&WellDegree="+instance[0].WellDegree+"&DegreeUser="+instance[0].DegreeUser+"&DegreeDate="+instance[0].DegreeDate+"&flag=1&entity=CrmDeliverTrainScb&id=" + vid + "&oid=" + OperatorInstanceId + "&tid=" + WorkflowInsId;
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    setTimeout(function () {
            var btn = document.getElementById("btnMarket");
            btn.disabled = true;
            var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
            setTimeout(function () { btn.disabled = false }, 10000);
        }, 10);           
}
//市场部赋值
var setMarketValue=function(){
    instance[0].InnerValue=$("#txtInner").val();
    instance[0].OutValue=$("#txtOut").val();
    instance[0].exp3 = $("#txtInnerGrade").val();
    instance[0].WellDegree=$("#txtSatisfy").val();
    instance[0].DegreeUser=$("#hdnMyd").val();
    instance[0].DegreeDate=$("#txtMydTime").val();
}
var setQdnxValue=function(){       
    instance[0].BeginDate=$("#txtStartDate").val();
    instance[0].PMemember=$("#Memember").val();
    instance[0].PExplain=$("#txtPmExplain").val();
    instance[0].ProjectUser=$("#AddUser").val();
    instance[0].ProjectDate=$("#txtAddTime").val();
}
var setValue = function(){  
    instance[0].Code = $("#Code").val();
    instance[0].exp2 = $("#OrderProductID").val();
    instance[0].DliverState=$("#DliverState").val();
    instance[0].ClassFrontServer = $("#ClassFrontServer").val();
    instance[0].WorkFlowId = WorkFlowId;
    instance[0].WorkTaskId = WorkTaskId;
    instance[0].WorkFlowInsId = $("#WorkFlowInsId").val();
    instance[0].WorkTaskInsId = $("#WorkTaskInsId").val();
    instance[0].CustomerMgr = $("#CustomerMgr").val();
    instance[0].CustomerDirector = $("#CustomerDirector").val();
    instance[0].CustomerManager = $("#CustomerManager").val();
}

function trySave(){
    var url = "../../Extend/AjaxData/CustomOperating.aspx?action="+action+"&cName="+encodeURI($("#CustomerName").val())+"&view="+strView+"&flag=1&entity="+entity+"";
    var formObject = document.getElementById('form2');
    YAHOO.util.Connect.setForm(formObject);
    var cObj = YAHOO.util.Connect.asyncRequest('POST', url, callback);
}

var responseSuccess = function (res) {
    try {                    
        var str = res.responseText;
        if (str == "1") { 
            RefreshDataParent();
            window.location.href = "../../Crm/BasePages/tooltip.aspx?worktaskInstanceId=" + getTsid;
        }
        else {
            alert(str);
        }
    } catch (e) {
    }
    finally {
    }
}

var responseFailure = function (error) {
    alert("数据错误：" + error.statusText);
}

var callback = {
    success: responseSuccess,
    failure: responseFailure
};

$(document).ready(function () {
    $('#txtStartDate').cld();
    $('#txtEndTime').cld();
    if($("#txtAddTime").val()==""&&strView!="check"){
        myDate = new Date(); 
        $("#txtAddTime").val(myDate.getYear()+"-"+(myDate.getMonth()+1)+"-"+myDate.getDate());
    }
});
</script>
</html>
